package communication;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

@SuppressWarnings("all")
public class Client extends Thread{

    private static String ip = "127.0.0.1";
    private Double x_target = null;
    private Socket socket = null;
    private String name = null;

    public Client(String name){
        this.name = name;
    }

    @Override
    public void run() {
        OutputStream out = null;
        InputStream in = null;
        try {
            socket = new Socket(ip,8848);
            out = socket.getOutputStream();
            in = socket.getInputStream();
            DataOutputStream dout = new DataOutputStream(out);
            DataInputStream din = new DataInputStream(in);
            SendThread it = new SendThread(dout);
            ReadThread ot = new ReadThread(din,ip,name);
            new Thread(ot).start();
            new Thread(it).start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}